# @Time  :2022/4/14 20:07
# @Author:Chen Jiayu
import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://mail.qq.com/")
time.sleep(10)
driver.switch_to.frame("login_frame")

# 填入自己的qq账号
driver.find_element(By.CSS_SELECTOR,'#u').send_keys('账号')
# 填入qq密码
driver.find_element(By.XPATH,'//*[@id="p"]').send_keys('密码')

driver.find_element(By.XPATH,'//*[@id="login_button"]').click()
driver.switch_to.default_content()
driver.implicitly_wait(20)
driver.find_element(By.XPATH,'//*[@id="composebtn"]').click()

driver.switch_to.frame('mainFrame')
time.sleep(5)
# 填入收件人的邮箱
driver.find_element(By.XPATH,'//*[@id="toAreaCtrl"]/div[2]/input').send_keys('收件人的邮箱')

driver.find_element(By.XPATH,'//*[@id="subject"]').send_keys("test")
driver.switch_to.frame(driver.find_element(By.XPATH,'//*[@class="qmEditorIfrmEditArea"]'))
driver.find_element(By.XPATH,'/html/body').click()
# 填写正文
driver.find_element(By.XPATH,'//*[@id="QQMAILSTATIONERY"]/div').send_keys("正文")
driver.switch_to.parent_frame()
driver.find_element(By.XPATH,'//*[@id="toolbar"]/div/a[1]').click()